Several efficacy trials of pre-exposure prophylaxis (daily antiretroviral therapy to prevent HIV acquisition in uninfected persons with sexual exposures) have failed because of poor adherence to medications. To ensure accurate, longitudinal measurement of pill ingestion with real-time monitoring, we plan to develop DOT Diary (D2), a smartphone application that uses artificial intelligence for measuring pill taking using Directly Observed Therapy. This patented technology will be combined with a daily sexual diary for use in future PrEP observational and efficacy trials. Such an approach provides aggregated data for individual participants, study sites, and trials overall, that facilitates realtime feedback to maximize adherence. We plan a 3 stage process for building and evaluating D2. First, we will assess the assess the reliability and validity of the automated DOT tool to identify attempts to cheat and over-report pill taking, as well as to evaluate the sensitivity of the measure to detecting 1- to 3-week interruptions in pill use. Second, we will develop and optimize the feasibility and acceptability of D2 for participants and study staff in tracking participation ver time, and providing real-time adherence feedback to study participants. Lastly, we will run a 24-week pilot study of D2 for high-risk men who have sex with men to evaluate the plausibility that this tool can be successfully used to measure and optimize adherence in future PrEP trials.